package cn.ocars.playgame.pencilstudy.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import cn.ocars.playgame.pencilstudy.services.MiniCPMVRecognitionService

/**
 * 简化书写演示界面
 * 使用MiniCPM-V 2.5模型进行书写评分
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SimplifiedWritingDemo(
    onBackClick: () -> Unit,
    modifier: Modifier = Modifier
) {
    var selectedCharacter by remember { mutableStateOf("一") }
    var resultText by remember { mutableStateOf("") }
    
    Scaffold(
        modifier = modifier.fillMaxSize(),
        topBar = {
            TopAppBar(
                title = { Text("MiniCPM-V 2.5 书写演示") },
                navigationIcon = {
                    IconButton(onClick = onBackClick) {
                        Icon(
                            painter = painterResource(android.R.drawable.ic_menu_revert),
                            contentDescription = "返回"
                        )
                    }
                }
            )
        }
    ) { innerPadding ->
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(innerPadding)
                .padding(16.dp),
            verticalArrangement = Arrangement.spacedBy(16.dp),
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text("当前字符: $selectedCharacter")
            
            // 字符选择按钮
            Column(
                verticalArrangement = Arrangement.spacedBy(8.dp)
            ) {
                listOf("一", "二", "三", "十", "人", "大", "小", "中", "上", "下").forEach { char ->
                    Button(onClick = { selectedCharacter = char }) {
                        Text(char)
                    }
                }
            }
            
            // 显示评分结果
            if (resultText.isNotEmpty()) {
                Text(resultText)
            }
        }
    }
}